<?php
require_once dirname(__FILE__).'/../lib/ProductPageHelper.class.php';

class productPageActions extends myFrontendAction
{
  public function preExecute()
  {
    parent::preExecute();
    
		$this->product  = $this->getRoute()->getProductObject();
		$this->category = $this->getRoute()->getCategoryObject();
  }


	/**
   * Default product page
   */
	public function executeIndex(sfWebRequest $request)
  {
    $parameter = new Parameter;
    
    // Whether we need to fetch parameter value
    if($request->getParameter('id', 0) > 0) {
      $this->value = $parameter->getValueById($request->getParameter('id', 0), $this->getUser());
      
      if($this->value) {
        $this->active = $request->getParameter('id', 0);
      } else $this->active = false;
    }
    
    // Fetching parameters for tabs
    $this->tabs = $parameter->getConnectedParams(
      $this->product->getId(),
      $this->getUser()
    );
    
    // Fetching product pictures (used by fancybox)
    $this->productPictures = Doctrine::getTable('ProductPictures')->getProductPictures(
      $this->getUser(),
      $this->product->getId()
    );
    
    
   // echo '<pre>';
    //print_r($this->value->toArray());
    //exit;
	}
  

	public function executePrint(sfWebRequest $request){
		$this->setLayout(false);
	}
}